package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * 销售发货单实体类
 * @author wyx
 * @version 2.0.0
 * @date 2021-12-27
 */
@Entity
@Table(schema = "public", name = "ord_sell_delivery_goods")
public class SellDeliveryGoodsDO implements Serializable {
    private static final long serialVersionUID = -5612468822368899252L;

    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_sell_delivery_goods_seq")
    @SequenceGenerator(sequenceName = "ord_sell_delivery_goods_seq", name = "ord_sell_delivery_goods_seq", allocationSize = 1)
    private Long id;

    /**
     * 订单编号
     */
    @Column(columnDefinition = "varchar(20)")
    private String orderNo;

    /**
     * 单据类型：1、销售发货单 2、采购收货单
     */
    @Column(columnDefinition = "int")
    private Integer type;

    /**
     * 批次号
     */
    @Column(columnDefinition = "int8")
    private Integer batchNo;

    /**
     * 发货单号
     */
    @Column(columnDefinition = "varchar(50)")
    private String deliveryOrderNo;

    /**
     * 对应仓库
     */
    @Column(columnDefinition = "varchar(30)")
    private String inventoryName;

    /**
     * 对应仓库人员
     */
    @Column(columnDefinition = "varchar(12)")
    private String inventoryRole;

    /**
     * 单据摘要
     */
    @Column(columnDefinition = "varchar(60)")
    private String digest;

    /**
     * 买方（采购）会员Id
     */
    @Column
    private Long buyerMemberId;

    /**
     * 采购会员角色Id
     */
    @Column
    private Long buyerRoleId;

    /**
     * 采购会员名称
     */
    @Column(columnDefinition = "varchar(200)")
    private String buyerMemberName;

    /**
     * 卖方（供应）会员Id
     */
    @Column
    private Long vendorMemberId;

    /**
     * 卖方（供应）会员角色Id
     */
    @Column
    private Long vendorRoleId;

    /**
     * 卖方（供应）会员名称
     */
    @Column(columnDefinition = "varchar(200)")
    private String vendorMemberName;

    /**
     * 备注
     */
    @Column(columnDefinition = "varchar(160)")
    private String remark;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime createTime;

    /**
     * 多对一双向关联订单
     */
    @Column
    private Long orderId;
//    @JsonBackReference
//    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
//    @JoinColumn(name = "order_id")
//    private OrderDO order;

    /**
     * 发货商品明细
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "deliveryGoods", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private Set<SellDeliveryGoodsDetailDO> detailList;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(Integer batchNo) {
        this.batchNo = batchNo;
    }

    public String getDeliveryOrderNo() {
        return deliveryOrderNo;
    }

    public void setDeliveryOrderNo(String deliveryOrderNo) {
        this.deliveryOrderNo = deliveryOrderNo;
    }

    public String getInventoryName() {
        return inventoryName;
    }

    public void setInventoryName(String inventoryName) {
        this.inventoryName = inventoryName;
    }

    public String getInventoryRole() {
        return inventoryRole;
    }

    public void setInventoryRole(String inventoryRole) {
        this.inventoryRole = inventoryRole;
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    public Long getBuyerMemberId() {
        return buyerMemberId;
    }

    public void setBuyerMemberId(Long buyerMemberId) {
        this.buyerMemberId = buyerMemberId;
    }

    public Long getBuyerRoleId() {
        return buyerRoleId;
    }

    public void setBuyerRoleId(Long buyerRoleId) {
        this.buyerRoleId = buyerRoleId;
    }

    public String getBuyerMemberName() {
        return buyerMemberName;
    }

    public void setBuyerMemberName(String buyerMemberName) {
        this.buyerMemberName = buyerMemberName;
    }

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public String getVendorMemberName() {
        return vendorMemberName;
    }

    public void setVendorMemberName(String vendorMemberName) {
        this.vendorMemberName = vendorMemberName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Set<SellDeliveryGoodsDetailDO> getDetailList() {
        return detailList;
    }

    public void setDetailList(Set<SellDeliveryGoodsDetailDO> detailList) {
        this.detailList = detailList;
    }
}
